package com.letv.whatslive.model.convert;

import com.letv.whatslive.model.Start_Image;
import com.letv.whatslive.model.utils.ObjUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

//2015.11.4

/**
 * Created by shenyue on 2015/11/4.
 */
public class Start_ImageConvert {
    public static DBObject castStart_ImageToDBObject(Start_Image start_Image) {
        DBObject dbo = new BasicDBObject();
        if (start_Image.getId() != null) {
            dbo.put("_id", start_Image.getId());
        }


        dbo.put("deviceType", ObjUtils.toInteger(start_Image.getDeviceType(), 0));
        dbo.put("picSpec", ObjUtils.toString(start_Image.getPicSpec(), ""));
        dbo.put("constantId", ObjUtils.toLong(start_Image.getConstantId(), 0l));
        dbo.put("variableId", ObjUtils.toLong(start_Image.getVariableId(), 0l));
        return dbo;


//        DBObject dbo = new BasicDBObject();
//        if (device.getId() != null) {
//            dbo.put("_id", device.getId());
//        }
//        dbo.put("platformId",device.getPlatformId());
//        dbo.put("sysVer", device.getSysVer());
//        dbo.put("model", device.getModel());
//        dbo.put("appVer", device.getAppVer());
//        dbo.put("corporationId", device.getCorporationId());
//        dbo.put("channelId", device.getChannelId());
//        return dbo;
    }

    public static Start_Image castDBObjectToStart_Image(DBObject dbObject) {
        Start_Image start_Image = new Start_Image();
        if (dbObject != null) {
            start_Image.setId(ObjUtils.toLong(dbObject.get("_id")));

            start_Image.setDeviceType(ObjUtils.toInteger(dbObject.get("deviceType")));
            start_Image.setPicSpec(ObjUtils.toString(dbObject.get("picSpec")));
            start_Image.setConstantId(ObjUtils.toLong(dbObject.get("constantId")));
            start_Image.setVariableId(ObjUtils.toLong(dbObject.get("variableId")));
        }
        return start_Image;
    }
}
